MPEG4AVC (Motion Pictures Experts Group 4 Advanced Video Coding) standard, which is a standard for compression encoding of images, defines a skip mode and a spatial direct mode as encoding modes.
When compression encoding (hereinafter, also referred to as simply “encoding”) a target image (hereinafter, referred to as “encoding target image”) in units of macroblocks of a predetermined size, for example, of 16*16 pixels, both of these encoding modes calculate the motion vector of the macroblock being encoded (hereinafter, referred to as “encoding target block”) and the reference image number (hereinafter, a set of a motion vector and a reference image number are referred to as “motion information”) identifying the reference image, based on the motion information of a plurality of macroblocks (hereinafter, referred to as “adjacent blocks”) adjacent to the encoding target block, the reference image being equivalent in size with the encoding target block and used to predict an image of the encoding target block. After that, these encoding modes encode the difference information which is information showing the difference between the prediction image, of the encoding target block, predicted based on the calculated motion information, and the original image of the encoding target block.
In other words, because the motion information of the macroblock encoded in the skip mode or the spatial direct mode (hereinafter, also referred to as “skip mode or the like”) can be calculated using the motion information of the adjacent blocks when the macroblock is decoded, it is not necessary to encode the motion information of the encoding target block. Thus, it is necessary only to encode the difference information indicating the difference between the prediction image of the encoding target block and the original image of the encoding target block. Accordingly, code amounts can be reduced by performing encoding in the skip mode or the like.
One conventionally known technique processes macroblocks in parallel using a pipeline structure in order to speed up encoding processing of an image.
As described above, in order to encode the encoding target block in the skip mode or the like, the motion information of the adjacent blocks are required.
For example, assume a case where the pipeline is divided into a first stage and a second stage, the first stage sequentially calculating the motion information of each macroblock encoded in the skip mode or the like, and the second stage, with respect to a macroblock which has been processed by the first stage, judging whether or not to perform the encoding in the skip mode or the like based on the code amount in the skip mode. In this case, when the processing by the first stage starts, if the processing by the second stage has not been completed on all the adjacent blocks of the encoding target block, the encoding mode has not been determined for all of the adjacent blocks.
In other words, the motion information has not been determined for all of the adjacent blocks, and thus, in the first stage, the motion information of the encoding target block cannot be calculated in the skip mode or the like.
An example of a technique for solving this problem is adopted by an image encoding apparatus disclosed by Patent Document 1. In the following, the image encoding apparatus according to Patent Document 1 is described.
The image encoding apparatus according to Patent Document 1 encodes the encoding target image in units of macroblocks which are processed in parallel using a pipeline structure. Starting from the upper left macroblock of the encoding target image, the image encoding apparatus processes one row of macroblocks in the horizontal direction, moves on to process the next row, and sequentially processes the macroblocks up to the bottom right macroblock.
In a case where the motion information of the macroblock (hereinafter, referred to as “previous block”) on the left of the encoding target block has not been calculated when beginning to process the encoding target block, the image encoding apparatus of Patent Document 1 uses a block (hereinafter, referred to as “vicinity block”) on the left of the previous block, for which the motion vector has been calculated, instead of using the previous block, to generate the motion information of the encoding target block in the skip mode.
After that, upon completion of calculating the motion information of the previous block, the image encoding apparatus confirms whether the calculated motion information of the previous block and the motion information of the vicinity block match each other, and, if these two match each other, is able to encode the encoding target block in the skip mode or the like.
Thus, even when the calculation of the motion information of the previous block has not been completed, the image encoding apparatus of Patent Document 1 calculates the motion vector of the encoding target block using the motion information of the vicinity block, thereby realizing speeding-up of the encoding processing without hindering the pipelined parallel processing.
Patent Document 1: Japanese Patent Publication No. 3879741